<!DOCTYPE html>
<html>
#{include file="header.html"}#
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
  <div class="row">
    <div class="col-sm-12">
      <div class="ibox float-e-margins">
        <div class="ibox-title">
          <h5><i class="fa fa-home"></i>全部订单</h5>
        </div>

        <div class="ibox-content table-responsive">
          <form id="pagerForm" method="post"  class="form-inline">
			  <div class="row panel ">
              <div class="col-sm-12 m-b-xs">
                <div data-toggle="buttons" class="btn-group">
                  <label class="btn btn-info btn-outline ajaxSearchForm active">
                    <input type="radio" value="" name="status" id="option1" checked>
                    全部</label>
                  <label class="btn btn-info btn-outline ajaxSearchForm">
                    <input type="radio" value="-1" name="status" id="option2">
                    待付款</label>
                  <label class="btn btn-sm btn-info btn-outline ajaxSearchForm">
                    <input type="radio" value="1" name="status" id="option3">
                    待发货</label>
                  <label class="btn btn-sm btn-info btn-outline ajaxSearchForm">
                    <input type="radio" value="2" name="status" id="option4">
                    已发货</label>
                  <label class="btn btn-sm btn-info btn-outline ajaxSearchForm">
                    <input type="radio" value="3" name="status" id="option5">
                    已收货</label>
                  <label class="btn btn-sm btn-info btn-outline ajaxSearchForm">
                    <input type="radio" value="4" name="status" id="option6">
                    已完成</label>
                  <label class="btn btn-sm btn-info btn-outline ajaxSearchForm">
                    <input type="radio" value="10" name="status" id="option7">
                    已关闭</label>
					<label class="btn btn-sm btn-info btn-outline ajaxSearchForm">
                    <input type="radio" value="11" name="status" id="option8">
                    退款中</label>
                </div>
              </div>
            </div>
            <div class="row">
              <div class="col-sm-3 m-b-xs">
				  		<a class="btn btn-info" href="#{$smarty.const.ACT}#/admin/Shop/shop_add/">导出数据</a>
                <div class="btn-group">
                  <button data-toggle="dropdown" class="btn btn-danger dropdown-toggle">批量操作 <span class="caret"></span></button>
                  <ul class="dropdown-menu">
                    <li><a href="javascript:void(0)" class="batch_operation" data-act="recommend">批量推荐</a></li>
                    <li><a href="javascript:void(0)" class="batch_operation" data-act="recommend_off">取消推荐</a></li>
                    <li class="divider"></li>
                    <li><a href="javascript:void(0)" class="batch_operation" data-act="online">批量上架</a></li>
                    <li><a href="javascript:void(0)" class="batch_operation" data-act="offline">批量下架</a></li>
                    <li class="divider"></li>
                    <li><a href="javascript:void(0)" class="batch_operation" data-act="del">批量删除</a></li>
                  </ul>
                </div>
              </div>
              <div class="col-sm-9 m-b-xs text-right" id="date_1"> 下单时间：
                <div class="input-daterange input-group" id="datepicker1">
                  <input type="text" class="input-sm form-control" name="sdt1" placeholder="选择开始时间"/>
                  <span class="input-group-addon">到</span>
                  <input type="text" class="input-sm form-control" name="edt1" placeholder="选择结束时间" />
                </div>
                <div class="btn-group">
                  <button data-toggle="dropdown" class="btn  dropdown-toggle"><span class="caret"></span></button>
                  <div class="dropdown-menu">
                    <div class="ibox-content">
                      <div class="form-group"> 
						  			<label>用户</label>
                        <input type="email" placeholder="用户名" class="form-control">
                      </div>
						<div class="form-group"> 
						  			<label>用户</label>
                        <input type="email" placeholder="用户名" class="form-control">
                      </div>
						<div class="form-group"> 
						  			<label>用户</label>
                        <input type="email" placeholder="用户名" class="form-control">
                      </div>
						<div class="form-group"> 
						  			<label>用户</label>
                        <input type="email" placeholder="用户名" class="form-control">
                      </div>
						<div class="form-group"> 
						  			<label>用户</label>
                        <input type="email" placeholder="用户名" class="form-control">
                      </div>
						<div class="form-group"> 
						  			<label>用户</label>
                        <input type="email" placeholder="用户名" class="form-control">
                      </div>
						<div class="form-group">
							<button type="button" class="btn btn-primary btn-xs btn-block ajaxSearchForm"><i class="fa fa-search"></i> 搜索</button></div>
                    </div>
                  </div>
                </div>
                <div class="input-group"> 
							<span class="input-group-btn">
                  <button type="button" class="btn btn-primary ajaxSearchForm"><i class="fa fa-search"></i> 搜索</button>
                  </span> 
				  		</div>
              </div>
            </div>
          </form>
          <table class="table table-hover table-bordered sorttable 07fly-table" width="100%">
            <thead>
              <tr>
                <th width="5"><input type="checkbox" group="ids" class="checkboxCtrl"></th>
                <th>商品名称</th>
                <th width="120">商品清单</th>
                <th width="120">订单金额</th>
                <th width="120">收货信息</th>
                <th width="80">买家会员</th>
                <th width="80">交易状态</th>
                <th width="100" class="text-center">操作</th>
              </tr>
            </thead>
            <tbody>
            </tbody>
            <tfoot class="ibox-content">
              <tr>
                <td colspan="8" align="center"></td>
              </tr>
            </tfoot>
          </table>
        </div>
      </div>
    </div>
  </div>
</div>
</html>
<script src="#{$smarty.const.APP}#/View/template/js/content.js?v=1.0.0"></script>
<script id="tableListTpl" type="text/html">
<% for(var i=0;i<list.length;i++) { %>
	<tr>
		<td><input name="order_id" class="checkboxCtrlId" value="<%=list[i]['order_id']%>" type="checkbox"></td>
		<td colspan="2">
			<div class='row'><div class="col-sm-12"><p>订单编号：<%=list[i]['order_no']%> 下单时间：<%=list[i]['adt']%></p></div></div>
			
			<% for(var j=0;j<list[i]['order_list'].length;j++) { %>
			<div class="row">
				<div class="col-sm-2">
					<%if(list[i]['order_list'][j]['defaultpic'].length!=''){%>
						  <img src="<%=list[i]['order_list'][j]['defaultpic']%>" width="60" height="60">
			　		<%}else{%> 
　　　　　　				<img src="/upload/images/defaultpic.jpg" width="60" height="60">
	  				<%}%> 
				</div>
				<div class="col-sm-6"><a href="#{$smarty.const.ACT}#/admin/GoodsOrder/goods_order_info/order_id/<%=list[i]['order_id']%>/"><%=list[i]['order_list'][j]['goods_name']%></a><br><%=list[i]['order_list'][j]['sku_name']%></div>
				<div class="col-sm-2"><%=list[i]['order_list'][j]['sale_price']%>元
					<%if(list[i]['order_list'][j]['adjust_money']!='0.00'){%>
						<br>(调价：<%=list[i]['order_list'][j]['adjust_money']%>元)
					<%}%> 
				</div>
				<div class="col-sm-1"><%=list[i]['order_list'][j]['num']%>件</div>
			</div>
			<% } %>
		</td>
		<td>
			<%=list[i]['order_money']%><br>
			(含配送费:<%=list[i]['shipping_money']%>元)<br>
			<%if(list[i]['pay_mode']=='1'){%>
			线下支付
			<%}else{%>
			在线支付
			<%}%> 
		</td>
		<td><%=list[i]['receiver_name']%><br><%=list[i]['receiver_mobile']%> <br><%=list[i]['receiver_address']%>
		</td>
		<td><%=list[i]['buyer_member_name']%></td>
		<td>
<%if(list[i]['status']=='0'){%>待付款<%}%>
<%if(list[i]['status']=='1'){%>待发货<%}%>
<%if(list[i]['status']=='2'){%>已发货<%}%>
<%if(list[i]['status']=='3'){%>已收货<%}%>
<%if(list[i]['status']=='4'){%>已完成<%}%>
<%if(list[i]['status']=='10'){%>已关闭<%}%>
<%if(list[i]['status']=='11'){%>退款中<%}%>
		</td>
		<td class='text-center'>
		<p><a href="#{$smarty.const.ACT}#/admin/GoodsOrder/goods_order_detail/order_id/<%=list[i]['order_id']%>/"  data-id="<%=list[i]['order_id']%>" data-act="info">订单详细</a></p>
		<%if(list[i]['status']=='0'){%>
			<p><a href="javascript:void(0)" class="single_operation" data-id="<%=list[i]['order_id']%>" data-act="pay_mode">线下支付</a></p>
			<p><a href="javascript:void(0)" class="single_operation" data-id="<%=list[i]['order_id']%>" data-act="close">关闭交易</a></p>
			<p><a href="javascript:void(0)" class="single_operation" data-id="<%=list[i]['order_id']%>" data-act="modify_price">修改价格</a></p>
		<%}%>
		<%if(list[i]['status']=='1'){%>
			<p><a href="javascript:void(0)" class="single_operation" data-id="<%=list[i]['order_id']%>" data-act="send_goods">发货</a></p>
			<p><a href="javascript:void(0)" class="single_operation" data-id="<%=list[i]['order_id']%>" data-act="modify_address">修改地址</a></p>
		<%}%>
		<%if(list[i]['status']=='2'){%>
			<p><a href="javascript:void(0)" class="single_operation" data-id="<%=list[i]['order_id']%>" data-act="logistics">查看物流</a></p>
			<p><a href="javascript:void(0)" class="single_operation" data-id="<%=list[i]['order_id']%>" data-act="received">确认收货</a></p>
		<%}%>
		<%if(list[i]['status']=='3'){%>
			<p><a href="javascript:void(0)" class="single_operation" data-id="<%=list[i]['order_id']%>" data-act="logistics">查看物流</a></p>
		<%}%>
			<p><a href="javascript:void(0)" class="single_operation" data-id="<%=list[i]['order_id']%>" data-act="remarks">备注</a></p>
		</td>
	</tr>
<% } %>
</script>

<script type="text/javascript">
var ajaxUrl='#{$smarty.const.ACT}#/admin/GoodsOrder/goods_order_json/';
$(document).ready(function () {
	turnPage(1);//页面加载时初始化分页

  $('#date_1 .input-daterange').datepicker({
		keyboardNavigation: false,
		forceParse: false,
		autoclose: true
	});
	
	//批量操作
	$("body").on("click", ".batch_operation", function() {
		batch_act =$(this).attr("data-act")
		var chk_value =[]; 
    	$("tbody input[class='checkboxCtrlId']:checked").each(function(){ 
        chk_value.push($(this).val()); 
		}); 
		order_id_txt=chk_value.join(",");
		if(batch_act=="recommend"){
		   act_url="#{$smarty.const.ACT}#/admin/GoodsOrder/goods_modify_recommend/";
		}else if(batch_act=="recommend_off"){
			act_url="#{$smarty.const.ACT}#/admin/GoodsOrder/goods_modify_recommend_off/";
		}else if(batch_act=="del"){
			act_url="#{$smarty.const.ACT}#/admin/GoodsOrder/goods_order_del/";
		}else if(batch_act=="modify_price"){
			act_url="#{$smarty.const.ACT}#/admin/GoodsOrder/goods_modify_online/";
		}else if(batch_act=="send_goods"){
			act_url="#{$smarty.const.ACT}#/admin/GoodsOrder/goods_send_goods/";
		}
    //alert(chk_value.length==0 ?'你还没有选择任何内容！':chk_value); 
		$.ajax({
			type: "POST",
			url: act_url,
			data:{"order_id":order_id_txt},
			dataType:"json",
			success: function(data){
				if(data.statusCode=='200'){
					layer.msg('操作成功', {icon: 1}); 
				}
			},
			complete: function () {//完成响应
			}
		});
	});
	
	$("body").on("click", ".single_operation", function() {
		order_id =$(this).attr("data-id");
		single_act =$(this).attr("data-act")
		if(single_act=="pay_mode"){
			act_url="#{$smarty.const.ACT}#/admin/GoodsOrder/goods_order_pay_mode/";
		}else if(single_act=="close"){
			act_url="#{$smarty.const.ACT}#/admin/GoodsOrder/goods_order_close/";
		}else if(single_act=="modify_price"){
			act_url="#{$smarty.const.ACT}#/admin/GoodsOrder/goods_order_modify_price/";
			layer.open({
				type: 2,
				title: '修改价格',
				shadeClose: true,
				fixed: false, //不固定
				area: ['800px', '500px'],
				content: '#{$smarty.const.ACT}#/admin/GoodsOrder/goods_order_modify_price/order_id/'+order_id+'/' //iframe的url
			});			
			return false;	
		}else if(single_act=="send_goods"){//发货
			layer.open({
				type: 2,
				title: '发货',
				shadeClose: true,
				fixed: false, //不固定
				area: ['800px', '500px'],
				content: '#{$smarty.const.ACT}#/admin/GoodsOrder/goods_order_send/order_id/'+order_id+'/' //iframe的url
			});			
			return false;	
		}else if(single_act=="modify_address"){//修改发货地址
			act_url="#{$smarty.const.ACT}#/admin/GoodsOrder/goods_order_modify_address/";
			layer.open({
				type: 2,
				title: '发货',
				shadeClose: true,
				fixed: false, //不固定
				area: ['800px', '400px'],
				content: '#{$smarty.const.ACT}#/admin/GoodsOrder/goods_order_modify_address/order_id/'+order_id+'/' //iframe的url
			});			
			return false;			
			
		}else if(single_act=="received"){
			act_url="#{$smarty.const.ACT}#/admin/GoodsOrder/goods_order_received/";
		}else if(single_act=="logitics"){
			act_url="#{$smarty.const.ACT}#/admin/GoodsOrder/goods_order_logitics/";
		}else if(single_act=="remarks"){
			act_url="#{$smarty.const.ACT}#/admin/GoodsOrder/goods_order_remarks/";
			layer.open({
				type: 2,
				title: '备注信息',
				shadeClose: true,
				fixed: false, //不固定
				area: ['400px', '300px'],
				content: '#{$smarty.const.ACT}#/admin/GoodsOrder/goods_order_remarks/order_id/'+order_id+'/' //iframe的url
			});			
			return false;
		}
		$.ajax({
			type: "POST",
			url: act_url,
			data:{"order_id":order_id},
			dataType:"json",
			success: function(data){
				if(data.rtnstatus=='success'){
					layer.msg('操作成功', {icon: 1}); 
				}
			}
		});
	});
	
	
});
</script>